<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/bootstrap-table.min.css">
    <script src="js/jquery-3.3.1.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/jquery.form.js"></script>
    <script src="/js/bootstrap-table.min.js"></script>
    <script src="/js/bootstrap-table-zh-CN.min.js"></script>
    <style>
        body{
            background:url("/img/timg.jpg")  no-repeat center center;
            background-size:cover;
            background-attachment:fixed;
            background-color:#CCCCCC;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column " >
            <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
                <div class="navbar-header">
                </div>
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        <li class="active">

                            <a href="#">首页</a>
                        </li>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                        <li>
                            <a href="#">发现</a>
                        </li>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                        <li>
                            <a href="#">话题</a>
                        </li>
                    </ul>
                    <form class="navbar-form navbar-left" role="search">
                        <div class="form-group">
                            <input type="text" class="form-control" placeholder="热门话题" />
                        </div> <button type="submit" class="btn btn-default">搜索</button>
                    </form>
                    <ul class="nav navbar-nav navbar-right">
                        <li>
                            <a href="/login.html"><button class="btn btn-primary">登录</button></a>
                        </li>
                        <li>
                            <a href="/register.html"><button class="btn btn-primary">注册</button>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</a>
                        </li>
                    </ul>
                </div>

            </nav>
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-4 column">
        </div>
        <div class="col-md-4 column">
            <div class="row clearfix">
                <div class="col-md-12 column">
                </div>
            </div>
            <form role="form">
                <br>
                <br>
                <br>
                <br>
                <br>
                <br>
                <br>
                <br>
                <div class="form-group">
                    <label for="exampleInputUsername">用户名:</label>
                    <input type="text" class="form-control" id="exampleInputUsername" placeholder="请输入您要找回的账号" required="" />
                    <span id="user_msg" colour="red"></span>
                </div>
                <div class="form-group">
                    <label for="exampleInputPhone">手机号:</label>
                    <input type="password" class="form-control" id="exampleInputPhone" placeholder="请输入您要找回账号的手机号" required="" />
                </div>
                <div class="form-group">
                    <label for="exampleInputPassword">新密码:</label>
                    <input type="password" class="form-control" id="exampleInputPassword" placeholder="请设置您的新密码" required=""/>
                </div>
                <br>
                <button type="button" id="submit1" name="submit1" class="btn btn-default">提交</button>
            </form>
        </div>
        <div class="col-md-4 column">
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
   $(function () {
       $("#exampleInputUsername").blur(function () {
           var username= $("#exampleInputUsername").val()
           var checkPasswordResult = document.getElementById("user_msg");
           console.log(username);
           var user1={username :username}
           $.post("/user/regist",user1,function (resp) {
                if (resp == "success") {
                    console.log(1);
                    checkPasswordResult.innerHTML = "用户名不存在";
                }else {
                    checkPasswordResult.innerHTML = "";
                }
           })
       })

       $("#submit1").click(function () {
           var username=$("#exampleInputUsername").val()
           console.log("姓名"+username);
           var phone=$("#exampleInputPhone").val()
           console.log("手机号"+phone);
           var password=$("#exampleInputPassword").val()
           console.log("新密码"+password);
           $.ajax({
               url:"/user/changePassword",
               type:"post",
               data:{
                   "username":username,
                   "phone":phone,
                   "password":password
               },
               dataType:"json",
               success:function (data) {
                   console.log(data);
                   console.log(1);
                   if ("success"== data.message){
                       alert("修改成功")
                      location.href="login.html"
                   } else {
                       alert("修改失败")
                   }
               }
           })
       })
   })
</script>
</html>